<?php
session_start();
if(($_SESSION['datos_admin']['estado'] == "autenticado") && ($_SESSION['datos_admin']['tipo'] == 2)) {

include("header.php");

$mydirname = basename( dirname( __FILE__ ) ) ;

$myts =& MyTextSanitizer::getInstance();
$module_id = $xoopsModule->getVar('mid');

/* if (is_object($xoopsUser)) {
    $groups = $xoopsUser->getGroups();
} else {
	$groups = XOOPS_GROUP_ANONYMOUS;
}

$gperm_handler =& xoops_gethandler('groupperm');

if (isset($_POST['item_id'])) {
    $perm_itemid = intval($_POST['item_id']);
} else {
    $perm_itemid = 0;
}
//If no access
if (!$gperm_handler->checkRight("resume_submit", $perm_itemid, $groups, $module_id)) {
    redirect_header(XOOPS_URL."/modules/$mydirname/index2.php", 3, _NOPERM);
    exit();
} */


/**
 * Funci�n para borrar una hoja de vida
 *
 * @param int $lid: identificador �nico de las hojas de vida
 * @param boolean $ok: variable que confirma la eliminacdi�n ($ok=1) o no ($ok=0) de la hoja de vida
 */
function ResumeDel($lid, $ok)
{
	global $xoopsDB, $xoopsUser, $xoopsConfig, $xoopsTheme, $xoopsLogger, $mydirname;

	$result = $xoopsDB->query("select usid, resume FROM ".$xoopsDB->prefix("jobs_resume")." where lid=$lid");
	list($usid, $resume) = $xoopsDB->fetchRow($result);

	if ($xoopsUser) {
		$calusern = $xoopsUser->getVar("uid", "E");
		if ($usid == $calusern) {
			if($ok==1) {
			    $xoopsDB->queryf("delete from ".$xoopsDB->prefix("jobs_resume")." where lid=$lid");
				if($resume){
					$destination = XOOPS_ROOT_PATH."/modules/$mydirname/resumes";
					if (file_exists("$destination/$resume")) {
						unlink("$destination/$resume");
					}
				}
				redirect_header("index2.php",1,_JOBS_RES_JOBDEL);
				exit();

			} else {
				echo "<table width='100%' border='0' cellspacing='1' cellpadding='8'><tr class='bg4'><td valign='top'>\n";

				echo "<br /><center>";
				echo "<b>"._JOBS_SURDELANN."</b><br /><br />";
			}
			echo "[ <a href=\"modresume.php?op=ResumeDel&amp;lid=$lid&amp;ok=1\">"._JOBS_OUI."</a> | <a href=\"index2.php\">"._JOBS_NON."</a> ]<br /><br />";
			echo "</td></tr></table>";
		}
	}
}



function ModResume($lid = ""){
	include_once (XOOPS_ROOT_PATH."/modules/jobs/include/functions.php");
	
	if ('autenticado' == $_SESSION['datos_admin']['estado']) {
		formUser($_SESSION['datos_admin']['user']);
	}
}


/**
 * Funci�n para modificar una hoja de vida
 *
 * @param int $lid: n�mero que identifica las hojas de vida
 */
function ModResume2($lid)
{
	//global $xoopsDB, $xoopsModule, $xoopsConfig, $xoopsUser, $monnaie, $moderated, $photomax, $ynsalary, $xoopsTheme, $myts, $xoopsLogger;
	global $xoopsDB, $xoopsModule, $xoopsConfig, $xoopsModuleConfig, $xoopsUser, $xoopsTheme, $myts, $xoopsLogger, $mydirname;

	$token = $GLOBALS['xoopsSecurity']->createToken();
	
	$wysiwyg_folder = XOOPS_ROOT_PATH."/class/wysiwyg";
	
	if ( file_exists( $wysiwyg_folder ) && ($xoopsModuleConfig['koivi'] == '1')) {
	include_once XOOPS_ROOT_PATH."/class/xoopsformloader.php";
	include_once XOOPS_ROOT_PATH . "/class/wysiwyg/formwysiwygtextarea.php";
	}else{
	include_once (XOOPS_ROOT_PATH."/include/xoopscodes.php");
	}
	
	echo "<script language=\"javascript\">\nfunction CLA(CLA) { var MainWindow = window.open (CLA, \"_blank\",\"width=500,height=300,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no\");}\n</script>";

	include_once(XOOPS_ROOT_PATH."/class/xoopstree.php");
	$mytree = new XoopsTree($xoopsDB->prefix("jobs_res_categories"),"cid","pid");
	
		
// Detecci�n de errores
     echo "<script type=\"text/javascript\">

function validarEmail(valor) {
 re=/^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$/
    if(!re.exec(valor))    {
       // return false;
return true
    }else{
        return true;
    }
}


           function verify() {
		        var a = document.add.email.value;
                var filter=/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+.[A-Za-z0-9_.]+[A-za-z]$/;
				
                var msg = \""._JOBS_VALIDERORMSG."\\n__________________________________________________\\n\\n\";
                var errors = \"FALSE\";

                if (document.add.name.value == \"\") {
                        errors = \"TRUE\";
                        msg += \""._VALIDNOMBRE."\\n\";
                } 
				if (document.add.tipoid.value == \"\") {
                        errors = \"TRUE\";
                        msg += \""._VALIDID."\\n\";
                }
				if (document.add.tel.value == \"\") {
                        errors = \"TRUE\";
                        msg += \""._VALIDTEL."\\n\";
                }
				if (document.add.town.value == \"\") {
                        errors = \"TRUE\";
                        msg += \""._VALIDDIR."\\n\";
                }
				if (document.add.barrio.value == \"\") {
                        errors = \"TRUE\";
                        msg += \""._VALIDBARRIO."\\n\";
                }			
				if (document.add.ciudad.value == \"\") {
                        errors = \"TRUE\";
                        msg += \""._VALIDCIUDAD."\\n\";
                }			
				if (document.add.email.value == \"\") {
                        errors = \"TRUE\";
                        msg += \""._VALIDEMAIL."\\n\";
                }
				
				if (a.length != 0) {     
                  if (!validarEmail(a)) {
			           errors = \"TRUE\";
                       msg += \""._EMAIL_ERROR."\\n\";
			     }
			 }
			 
				if (document.add.estadocivil.value == \"\") {
                        errors = \"TRUE\";
                        msg += \""._VALIDESTADO."\\n\";
                }	
				if (document.add.ingles.value == \"\") {
                        errors = \"TRUE\";
                        msg += \""._VALIDINGLES."\\n\";
                }	
                if (document.add.title.value == \"\") {
                        errors = \"TRUE\";
                        msg += \""._VALIDCARGOS."\\n\";
                }
                 if (document.add.trabajo.value == \"\") {
                        errors = \"TRUE\";
                        msg += \""._VALIDTRABAJO."\\n\";
                }	
                 if (document.add.exp.value == \"\") {
                        errors = \"TRUE\";
                        msg += \""._VALIDEXP."\\n\";
                }	
                 if (document.add.salary.value == \"\") {
                        errors = \"TRUE\";
                        msg += \""._VALIDSALARIO."\\n\";
                }	
                if (document.add.perfil.value == \"\") {
                        errors = \"TRUE\";
                        msg += \""._VALIDPERFIL."\\n\";
                }		

                if (document.add.nomproyecto.value == \"\") {
                        errors = \"TRUE\";
                        msg += \"Debe ingresar un valor a nombre de proyecto\\n\";
                }		

                if (document.add.etnia.value == \"\") {
                        errors = \"TRUE\";
                        msg += \"Debe especificar si pertenece a algun grupo o etnia\\n\";
                }		


                if (document.add.nomevento.value == \"\") {
                        errors = \"TRUE\";
                        msg += \"Debe especificar si pertenece a participado en eventos o conferencias\\n\";
                }		


                if (document.add.cargofunlam1.checked == \"\" && document.add.cargofunlam2.checked == \"\" && document.add.cargofunlam3.checked == \"\" && document.add.cargofunlam4.checked == \"\") {
                        errors = \"TRUE\";
                        msg += \"Debe especificar indicar si está vinculado a la FUNLAM\\n\";
                }		


                if (document.add.cargoeventos.value == \"\") {
                        errors = \"TRUE\";
                        msg += \"Debe seleccionar un cargo en los eventos\\n\";
                }		
									
                if (document.add.distinciones.value == \"\") {
                        errors = \"TRUE\";
                        msg += \"Debe ingresar un valor en las distinciones\\n\";
                }		
			         								
                if (errors == \"TRUE\") {
                        msg += \"__________________________________________________\\n\\n"._JOBS_VALIDMSG."\\n\";
                        alert(msg);

                        return false;
                }
          }
          </script>";
		
		  echo "<script type=\"text/javascript\">
	 function numeros(e) {
    tecla = (document.all) ? e.keyCode : e.which; 
    if (tecla==8) return true; 
    patron =/\d/; 
    te = String.fromCharCode(tecla); 
    return patron.test(te);
    } 
      </script>"; 
				
    $result = $xoopsDB->query("select lid, cid, name, title, tipoid, numid, sexo, exp, expire, private, programa, programa3, estadocivil, fechanac, etnia, tel, tel2, celular, salary, typeprice, date, email, submitter, usid, ciudad, town, barrio, perfil, trabajo, sector, empresa, telempresa, extempresa, cargo, empresanterior, estudios, area, institucion, ingles, idioma2, intereses, areainteres, proyectos, nomproyecto, evento, nomeventos, cargoeventos, cargofunlam, distinciones, valid, resume from ".$xoopsDB->prefix("jobs_resume")." where lid=$lid");
    list($lid, $cide, $name, $title, $tipoid, $numid, $sexo, $exp, $expire, $private, $programa, $programa3, $estadocivil, $fechanac, $etnia, $tel, $tel2, $celular, $salary, $typeprice, $date, $email, $submitter, $usid, $ciudad, $town, $barrio, $perfil, $trabajo, $sector, $empresa, $telempresa, $extempresa, $cargo, $empresanterior, $estudios, $area, $institucion, $ingles, $idioma2, $intereses, $areainteres, $proyectos, $nomproyecto, $evento, $nomeventos, $cargoeventos, $cargofunlam, $distinciones, $valid, $resume_old) = $xoopsDB->fetchRow($result);
	
	///////////////
	if ($_SESSION['datos_admin']['user'] == $numid){
	//////////////
	
	/* if ($xoopsUser) {
		$calusern = $xoopsUser->uid();
		if ($usid == $calusern) { */

			echo "<fieldset><legend style='font-weight: bold; color: #3366CC;'>"._JOBS_RES_MODIFICAR."</legend>";
			//echo "<b>"._JOBS_MODIFANN."</b><br /><br />";
	
		$name = $myts->makeTboxData4Edit($name);	
		$title = $myts->makeTboxData4Edit($title);
		$numid = $myts->makeTboxData4Edit($numid);
		$sexo = $myts->makeTboxData4Edit($sexo);
		$exp = $myts->makeTboxData4Edit($exp);
		$programa = $myts->makeTboxData4Edit($programa);
		$tel = $myts->makeTboxData4Edit($tel);
		$tel2 = $myts->makeTboxData4Edit($tel2);
		$celular = $myts->makeTboxData4Edit($celular);
		$salary = $myts->makeTboxData4Edit($salary);
		$submitter = $myts->makeTboxData4Edit($submitter);	
		$ciudad = $myts->makeTboxData4Edit($ciudad);
		$town = $myts->makeTboxData4Edit($town);
		$barrio = $myts->makeTboxData4Edit($barrio);
		$perfil = $myts->makeTboxData4Edit($perfil);
		$empresa = $myts->makeTboxData4Edit($empresa);
		$telempresa = $myts->makeTboxData4Edit($telempresa);
		$extempresa = $myts->makeTboxData4Edit($extempresa);
		$cargo = $myts->makeTboxData4Edit($cargo);
		$institucion = $myts->makeTboxData4Edit($institucion);
		
			$useroffset = "";
		    if($xoopsUser) {
				$timezone = $xoopsUser->timezone();
				if(isset($timezone)){
					$useroffset = $xoopsUser->timezone();
				}else{
					$useroffset = $xoopsConfig['default_TZ'];
				}
			}
			$dates = ($useroffset*3600) + $date;	
			$dates = formatTimestamp($date,"s");
		
		   	echo "<form action=\"modresume.php\" method=\"post\" enctype=\"multipart/form-data\" name=\"add\" onsubmit=\"return verify();\">";
		
// NUMERO Y FECHA DE PUBLICACION
			/* <tr><td class=\"odd\" width=\"35%\">"._JOBS_NUMANNN." </td><td class=\"odd\">$lid "._JOBS_DU." $dates</td>
			</tr>"; */
//
// NOMBRE DE QUIEN LA ENVIA
			/* <tr>
			<td class=\"even\" width=\"35%\">"._JOBS_SENDBY." </td><td class=\"even\">$submitter</td>
			</tr> */
//
		
           if ($sexo == 'masculino'){
			    $checkedm = "checked";
			}elseif ($sexo == 'femenino'){
			    $checkedf = "checked";
			}

			echo "<b>"._DATOS_PERSONALES."
			<table width='100%' class='outer' cellspacing='1'>			
			<tr>
			<td class=\"even\" width=\"35%\">"._NOMBRE_EGRESADO._AST." </td><td class=\"even\"><input type=\"text\" name=\"name\" size=\"50\" value=\"$name\" maxlength=\"100\"></td>
			</tr><tr>
			<td width='35%' class='odd'>"._TIPO_ID._AST." </td><td class='odd'>
			<select name=\"tipoid\">";
			
			$tipoidlist = array(_CEDULA,
		                        _EXTRANJERO,
		                        _OTRO,				           	                   
				);
				
				foreach ($tipoidlist as $value){
				    echo "<option value=\"{$value}\" ";
				    if ($value == $tipoid) {
				    	$selected = "selected";
				    }else {
				        $selected = "";
				    }
				    echo "{$selected}>{$value}</option>";
				}
				
			echo "</select></td>
			</tr><tr>
			<td width='35%' class='even'>"._NUMERO_ID." </td><td class='even'>$numid</td>
			</tr><tr>
			<td width='30%' class='odd'>"._FECHA_NACIMIENTO." </td><td class='odd'>
			$fechanac</td>
			</tr><tr>
			<td width='30%' class='even'>"._SEXO._AST." </td><td class='even'>
			<input type=\"radio\" name=\"sexo\" value=\"masculino\" {$checkedm}/>"._MASCULINO."
			<input type=\"radio\" name=\"sexo\" value=\"femenino\" {$checkedf}/>"._FEMENINO."</td>
			</tr><tr>
			<td width='35%' class='odd'>"._ESTADO_CIVIL._AST." </td><td class='odd'>
			<select name=\"estadocivil\">";
				
				$estadolist = array(_SOLTERO,
				                    _CASADO,
				                    _DIVORCIADO,
				                    _VIUDO,	
									_RELIGIOSO,			                   
				);
				
				foreach ($estadolist as $value){
				    echo "<option value=\"{$value}\" ";
				    if ($value == $estadocivil) {
				    	$selected = "selected";
				    }else {
				        $selected = "";
				    }
				    echo "{$selected}>{$value}</option>";
				}
															
			echo "</select></td>
			</tr><tr>
			<td class=\"even\" width=\"35%\">"._TELEFONO1._AST." </td><td class=\"even\"><input type=\"text\" name=\"tel\" size=\"20\" maxlength=\"20\" value=\"$tel\"></td>
			</tr><tr>
			<td width='30%' class='odd'>"._TELEFONO2." </td><td class='odd'><input type=\"text\" name=\"tel2\" size=\"20\" maxlength=\"20\" value=\"$tel2\"></td>
			</tr><tr>
			<td width='30%' class='even'>"._CELULAR_EGRESADO." </td><td class='even'><input type=\"text\" name=\"celular\" size=\"20\" maxlength=\"20\" value=\"$celular\"></td>
			</tr><tr>
			<td class=\"odd\" width=\"35%\">"._CIUDAD_EGRESADO._AST." </td><td class=\"odd\"><input type=\"text\" name=\"ciudad\" size=\"20\" maxlength=\"50\" value=\"$ciudad\">
			&nbsp;"._BARRIO_EGRESADO._AST."&nbsp;<input type=\"text\" name=\"barrio\" size=\"20\" maxlength=\"50\" value=\"$barrio\"/></td>
			</tr><tr>
			<td class=\"even\" width=\"35%\">"._DIRECCION_EGRESADO._AST." </td><td class=\"even\"><input type=\"text\" name=\"town\" size=\"50\" maxlength=\"50\" value=\"$town\"></td>
			</tr><tr>
			<td class=\"odd\" width=\"35%\">"._CORREO_EGRESADO._AST." </td><td class=\"odd\"><input type=\"text\" name=\"email\" size=\"50\" maxlength=\"50\" value=\"$email\"></td>
			</tr></table>
			
			<br><br><b>"._ESTUDIOS."
			<table width='100%' class='outer' cellspacing='1'>";
			
			// programa 1
			$car = $xoopsDB->query("select title, tipo FROM ".$xoopsDB->prefix("jobs_res_categories")." WHERE cid=$cide");
            list($nomcarrera, $tipo1) = $xoopsDB->fetchRow($car); 
			if ($tipo1 == "PR"){
			echo "<tr><td class=\"even\" width=\"35%\">"._PREGRADO." en :</td><td class=\"even\">$nomcarrera";
			echo "</td></tr>";
			} else {
			echo "<tr><td class=\"even\" width=\"35%\">"._POST." en :</td><td class=\"even\">$nomcarrera";
			echo "</td></tr>";
			}
			
			// programa 2
			$pro = $xoopsDB->query("select title, tipo FROM ".$xoopsDB->prefix("jobs_res_categories")." WHERE cid=$programa");
            list($nomprograma, $tipo2) = $xoopsDB->fetchRow($pro); 
			if ($nomprograma){
			if ($tipo2 == "PR"){
			echo "<tr><td class=\"even\" width=\"35%\">"._PREGRADO." en :</td><td class=\"even\">$nomprograma";		
			echo "</td></tr>";
			} else {
			echo "<tr><td class=\"even\" width=\"35%\">"._POST." en :</td><td class=\"even\">$nomprograma";		
			echo "</td></tr>";
			}
			}
			
			// programa 3
			$esp = $xoopsDB->query("select title, tipo FROM ".$xoopsDB->prefix("jobs_res_categories")." WHERE cid=$programa3");
            list($nomesp, $tipo3) = $xoopsDB->fetchRow($esp); 
			if ($nomesp){
			if ($tipo3 == "PR"){
			echo "<tr><td class=\"even\" width=\"35%\">"._PREGRADO." en :</td><td class=\"even\">$nomesp";		
			echo "</td></tr>";
			} else {
			echo "<tr><td class=\"even\" width=\"35%\">"._POST." en :</td><td class=\"even\">$nomesp";		
			echo "</td></tr>";
			}
			}
			
				echo "<tr>
				<td width='30%' class='odd'>Otros estudios </td><td class='odd'>
				<textarea name=\"area\" cols=\"28\" rows=\"4\" >$area</textarea>
				</td></tr>
				<tr>
				<td width='35%' class='odd'>"._NIVEL_INGLES._AST." </td><td class='odd'>
				<select name=\"ingles\">";
				
	            $ingleslist = array(_CERO,
				                      _MUYBASICO,
				                      _BASICO,
									  _INTERMEDIO,		
									  _ALTO,		
									  _MUYALTO,						           	                   
				);
				
				foreach ($ingleslist as $value){
				    echo "<option value=\"{$value}\" ";
				    if ($value == $ingles) {
				    	$selected = "selected";
				    }else {
				        $selected = "";
				    }
				    echo "{$selected}>{$value}</option>";
				}
				
                echo "</select></td>
                </tr><tr>
			    <td class=\"even\" width=\"35%\">"._OTROS_IDIOMAS." </td><td class=\"even\"><input type=\"text\" name=\"idioma2\" size=\"50\" maxlength=\"50\" value=\"$idioma2\"></td>
			    </tr><tr>
				<td width='35%' class='odd'>"._INTERESES." </td><td class='odd'>
				<select name=\"intereses\"><option></option>";
				
	            $intereseslist = array(_CURSOS,
				                      'Maestria',
                                                      'Especializaci&oacute;n',
                                                      'Doctorado',
				                      _DIPLOMADOS,							 					           	                   
				);
				
				foreach ($intereseslist as $value){
				    echo "<option value=\"{$value}\" ";
				    if ($value == $intereses) {
				    	$selected = "selected";
				    }else {
				        $selected = "";
				    }
				    echo "{$selected}>{$value}</option>";
				}
				
                echo "</select></td>
                </tr><tr>
			    <td class=\"even\" width=\"35%\">"._AREAINTERES." </td><td class=\"even\"><input type=\"text\" name=\"areainteres\" size=\"50\" maxlength=\"100\" value=\"$areainteres\"></td>
			    </tr></table>";
					
//Elige un tipo de salario de una lista				
				/* $result3 = $xoopsDB->query("select nom_price from ".$xoopsDB->prefix("jobs_price")." order by id_price");
				echo " <select name=\"typeprice\"><option value=\"$typeprice\">$typeprice</option>";
				while(list($nom_price) = $xoopsDB->fetchRow($result3)) {
					echo "<option value=\"$nom_price\">$nom_price</option>";
				}
				echo "</select>"; */
//				
                
				echo "<br><br><b>"._LABORAL."
			    <table width='100%' class='outer' cellspacing='1'>
			    <tr><td class=\"even\" width=\"35%\">"._JOBS_TITLE2._AST." </td><td class=\"even\"><input type=\"text\" name=\"title\" size=\"50\" maxlength=\"100\" value=\"$title\"></td>
			    </tr><tr>
				<td class=\"odd\" width=\"35%\">"._EXPERIENCIA_EGR._AST." </td><td class=\"odd\">
				<select name=\"exp\">";
			
			$explist = array(_EXP0, _EXP1, _EXP2, _EXP3, _EXP4, _EXP5, _EXP6,);
				
				foreach ($explist as $value){
				    echo "<option value=\"{$value}\" ";
				    if ($value == $exp) {
				    	$selected = "selected";
				    }else {
				        $selected = "";
				    }
				    echo "{$selected}>{$value}</option>";
				}
				
			echo "</select></td>
			</tr><tr>
				<td width='35%' class='even'>"._SIT_LABORAL._AST." </td><td class='even'>
				<select name=\"trabajo\">";
								
				$trabajolist = array(_DESEMPLEADO,
				                     _INDEPENDIENTE,
				                     _ASALARIADO,
				                     _PROPIETARIO,
				                     _JUBILADO,
				);
				
				foreach ($trabajolist as $value){
				    echo "<option value=\"{$value}\" ";
				    if ($value == $trabajo) {
				    	$selected = "selected";
				    }else {
				        $selected = "";
				    }
				    echo "{$selected}>{$value}</option>";
				}
				
				echo "</select></td>
				</tr><tr>
				<td width='30%' class='odd'>"._EMPRESA_EGRESADO." </td><td class='odd'><input type=\"text\" name=\"empresa\" size=\"50\" maxlength=\"100\" value=\"$empresa\" /></td>
				</tr><tr>
				<td width='30%' class='even'>"._SECTOR." </td><td class='even'>
				<select name=\"sector\"><option></option>";
								
				$sectorlist = array(_SECTOR1,
				                    _SECTOR7,
				                    _SECTOR2,
				                    _SECTOR3,
				                    _SECTOR4,
				                    _SECTOR5,
									_SECTOR6,
				);
				
				foreach ($sectorlist as $value){
				    echo "<option value=\"{$value}\" ";
				    if ($value == $sector) {
				    	$selected = "selected";
				    }else {
				        $selected = "";
				    }
				    echo "{$selected}>{$value}</option>";
				}
				
		        echo "</select></td>			
				</tr><tr>
				<td width='30%' class='odd'>"._EMPRESA_EGRESADO_TELEFONO." </td><td class='odd'><input type=\"text\" name=\"telempresa\" size=\"20\" maxlength=\"20\" value=\"$telempresa\" />
				&nbsp;"._EXT."&nbsp;<input type=\"text\" name=\"extempresa\" size=\"5\" maxlength=\"5\" value=\"$extempresa\" onKeypress=\"return numeros(event);\"/></td>
				</tr><tr>
				<td width='30%' class='even'>"._CARGO_EGRESADO." </td><td class='even'><input type=\"text\" name=\"cargo\" size=\"50\" maxlength=\"100\" value=\"$cargo\" /></td>
				</tr><tr>
				<td width='30%' class='odd'>"._EMPRESA_ANT." </td><td class='even'><input type=\"text\" name=\"empresanterior\" size=\"50\" maxlength=\"100\" value=\"$empresanterior\" /></td>
				</tr>
                                <tr>
				<td class=\"even\" width=\"35%\">"._SALARIO_EGRESADO._AST." </td><td class=\"even\">
				<select name=\"salary\">";
								
				$salariolist = array(_SALARIO1,
				                    _SALARIO2,
				                    _SALARIO3,
				);
				
				foreach ($salariolist as $value){
				    echo "<option value=\"{$value}\" ";
				    if ($value == $salary) {
				    	$selected = "selected";
				    }else {
				        $selected = "";
				    }
				    echo "{$selected}>{$value}</option>";
				}
				
		   echo "</select></td>			
</tr>
                                <tr>
				<td class=\"odd\" width=\"35%\">&Uacute;ltimo cargo desempe&ntilde;ado </td><td class=\"odd\">
<input type=\"text\" name=\"ultimo\" >				
	</td>			




				</tr></table><br><br>";
				echo "<table width='100%' class='outer' cellspacing='1'>
				<tr><td width='30%' class='odd'>"._PERFIL._AST._COPY."</td></tr>
				<tr><td class='odd'>";
			
			$wysiwyg_folder = XOOPS_ROOT_PATH."/class/wysiwyg";
	        if ( file_exists( $wysiwyg_folder) && ($xoopsModuleConfig['koivi'] == '1')) {
			$wysiwyg_perfil_area= new XoopsFormWysiwygTextArea( _PERFIL, perfil, $perfil, '100%', '200px','small');
			echo $wysiwyg_perfil_area->render();
			} else {
			ob_start();
			$GLOBALS["perfil"] = $perfil;
			xoopsCodeTarea("perfil",30,8);
			$xoops_codes_tarea = ob_get_contents();
			ob_end_clean();
			echo $xoops_codes_tarea; 
			}
																	
			echo "</td></tr>
			</table><br><br>";
				
				echo "<table width='100%' class='outer' cellspacing='1'>
				<b>"._PREGUNTAS."
				<br>Las siguientes preguntas, son requisitos indispensables ante el Ministerio de Educaci&oacute;n, como informaci&oacute;n b&aacute;sica de nuestros graduados:
";
			   echo "<tr>
			    <td width='35%' class='even'>"._ETNIA."</td><td class='even'><input type=\"text\" name=\"etnia\" value=\"$etnia\" size=\"30\" maxlength=\"50\" /></td>
			    </tr><tr>
				<td width='40%' class='odd'>"._PROYECTOS_FUNLAM." </td><td class='odd'>		
				<textarea name=\"nomproyecto\" cols=\"28\" rows=\"4\">{$nomproyecto}</textarea>
				</td>
				</tr><tr>
				<td width='35%' class='even'>"._EVENTOS_FUNLAM." </td><td class='even'>
				<textarea name=\"nomevento\" cols=\"28\" rows=\"4\">{$nomeventos}</textarea>
				</td>
				</tr><tr>
				<td width='35%' class='odd'>"._CARGO_EVENTOS." </td><td class='odd'>
				<select name=\"cargoeventos\"><option></option>";
				
				$cargolist = array(_CARGO1,
				                   _CARGO2,
				                  _CARGO3,
				                    _CARGO4,
									_CARGO5,
                                                  'Ninguno'		                   
				);
				
				foreach ($cargolist as $value){
				    echo "<option value=\"{$value}\" ";
				    if ($value == $cargoeventos) {
				    	$selected = "selected";
				    }else {
				        $selected = "";
				    }
				    echo "{$selected}>{$value}</option>";
				}
				
				$cargof = explode(',', $cargofunlam);
				
				$cargo1 = "";
				$cargo2 = "";
				$cargo3 = "";
				
				if (in_array('docente', $cargof)) {
					$cargo1 = "checked";
				}
				if (in_array('investigador', $cargof)) {
					$cargo2 = "checked";
				}
				if (in_array('administrativo', $cargof)) {
					$cargo3 = "checked";
				}
				if (in_array('ninguno', $cargof)) {
					$cargo4 = "checked";
				}
				
				echo "</select></td>
				</tr><tr>
				<td width='35%' class='even'>"._VINCULACION_FUNLAM."</td><td class='even'>
				<input type=\"checkbox\" value=\"docente\" name=\"cargofunlam1\" id=\"cargofunlam1\" {$cargo1}>Docente<br>
<input type=\"checkbox\" value=\"investigador\" name=\"cargofunlam2\" id=\"cargofunlam2\" {$cargo2}>Investigador<br>
<input type=\"checkbox\" value=\"administrativo\" name=\"cargofunlam3\" id=\"cargofunlam3\" {$cargo3}>Administrativo <br>
<input type=\"checkbox\" value=\"ninguno\" name=\"cargofunlam4\" id=\"cargofunlam4\" {$cargo4}>Ninguno
				";
				
				
				
				echo "</td>
				</tr><tr>
				<td width='35%' class='odd'>"._DISTINCIONES." </td><td class='odd'><textarea name=\"distinciones\" cols=\"28\" rows=\"4\">$distinciones</textarea></td>
				</tr></table><br>"._REQUERIDO2."<br>";
				
			echo "<table width='100%' class='outer' cellspacing='1'><tr>
			<td colspan=2><br /><br /><center><input type=\"submit\" value=\""._CAMBIAR."\">
			<input name=\"btncancelar\" type=\"button\" id=\"btncancelar\" onClick=\"self.location.href='index.php'\"  value=\""._CANCELAR."\"></center></td>
			</tr></table>";
			echo "<input type=\"hidden\" name=\"op\" value=\"ModResumeS\" />";
		
			if ($xoopsModuleConfig['moderate_resume'] == '1') {
			    echo "<input type=\"hidden\" name=\"valid\" value=\"No\" />";
				echo "<br />"._JOBS_MODIFBEFORE."<br />";
			} else {
				echo "<input type=\"hidden\" name=\"valid\" value=\"Yes\" />";
			}
						
			echo "<input type=\"hidden\" name=\"numid\" value=\"$numid\"/>";
			echo "<input type=\"hidden\" name=\"fechanac\" value=\"$fechanac\" />";
			echo "<input type=\"hidden\" name=\"cid\" value=\"$cide\" />";
			echo "<input type=\"hidden\" name=\"programa\" value=\"$programa\" />";
			echo "<input type=\"hidden\" name=\"programa3\" value=\"$programa3\" />";
			
		    echo "<input type=\"hidden\" name=\"token\" value=\"$token\" />";
	    	echo "<input type=\"hidden\" name=\"lid\" value=\"$lid\" />";
	    	echo "<input type=\"hidden\" name=\"date\" value=\"$date\" />";
	    	echo "<input type=\"hidden\" name=\"submitter\" value=\"$submitter\" />
			</form><br />";
		echo "</fieldset><br />"; 
    		//CloseTable();
   /*      }    
	} */
	}
	else{
	 echo "<script type=\"text/javascript\">
 history.go(-1);
 </script>";
	}
}

/**
 * Funci�n para actualizar las tablas 'jobs_resume' y 'egresados'
 *
 * @param int $lid
 * @param int $cat
 * @param string $name
 * @param string $title
 * @param string $tipoid
 * @param string $numid
 * @param string $sexo
 * @param string $exp
 * @param unknown_type $expire
 * @param unknown_type $private
 * @param int $programa
 * @param int $programa3
 * @param string $estadocivil
 * @param date $fechanac
 * @param string $etnia
 * @param string $tel
 * @param string $tel2
 * @param string $celular
 * @param string $salary
 * @param unknown_type $typeprice
 * @param string $date
 * @param string $email
 * @param unknown_type $submitter
 * @param string $ciudad
 * @param string $town
 * @param string $barrio
 * @param string $perfil
 * @param string $trabajo
 * @param string $sector
 * @param string $empresa
 * @param string $telempresa
 * @param string $extempresa
 * @param string $cargo
 * @param string $empresanterior
 * @param string $estudios
 * @param string $area
 * @param string $institucion
 * @param string $ingles
 * @param string $idioma2
 * @param string $intereses
 * @param string $areainteres
 * @param string $proyectos
 * @param string $nomproyecto
 * @param string $evento
 * @param string $nomeventos
 * @param string $cargoeventos
 * @param string $cargofunlam
 * @param string $distinciones
 * @param string $valid
 * @param unknown_type $resume
 * @param unknown_type $resume_old
 * @param unknown_type $resumeS_size
 * @param unknown_type $resumeS_name
 * @param unknown_type $_FILES
 * @param unknown_type $supprim
 * @param unknown_type $mydirname
 */
function ModResumeS($lid, $cat, $name, $title, $tipoid, $numid, $sexo, $exp, $expire, $private, $programa, $programa3, $estadocivil, $fechanac, $etnia, $tel, $tel2, $celular, $salary, $typeprice, $date, $email, $submitter, $ciudad, $town, $barrio, $perfil, $trabajo, $sector, $empresa, $telempresa, $extempresa, $cargo, $empresanterior, $estudios, $area, $institucion, $ingles, $idioma2, $intereses, $areainteres, $proyectos, $nomproyecto, $evento, $nomeventos, $cargoeventos, $cargofunlam, $distinciones, $valid, $resume, $resume_old, $resumeS_size, $resumeS_name, $_FILES, $supprim, $mydirname)
{
	global $xoopsDB, $xoopsConfig, $xoopsConfig, $xoopsModuleConfig, $myts, $xoopsLogger;

		if (!$GLOBALS['xoopsSecurity']->check(true, $_REQUEST['token'])) {
		   redirect_header(XOOPS_URL."/modules/$mydirname/index.php", 3, implode('<br />', $GLOBALS['xoopsSecurity']->getErrors()));
		}
		
		$destination = XOOPS_ROOT_PATH."/modules/$mydirname/resumes";
	
	if($supprim == "yes"){
		if (file_exists("$destination/$resume_old")) {
			 unlink("$destination/$resume_old");
		}
		
		$resume_old = "";
	}

	$name = $myts->makeTboxData4Save($name);	
	$title = $myts->makeTboxData4Save($title);
	$numid = $myts->makeTboxData4Save($numid);
	$exp = $myts->makeTboxData4Save($exp);
	$sexo = $myts->makeTboxData4Save($sexo);
	$programa = $myts->makeTboxData4Save($programa);
	$tel = $myts->makeTboxData4Save($tel);
	$tel2 = $myts->makeTboxData4Save($tel2);
	$celular = $myts->makeTboxData4Save($celular);
	$salary = $myts->makeTboxData4Save($salary);
	$submitter = $myts->makeTboxData4Save($submitter);	
	$town = $myts->makeTboxData4Save($town);
	$ciudad = $myts->makeTboxData4Save($ciudad);
	$barrio = $myts->makeTboxData4Save($barrio);
	$perfil = $myts->makeTboxData4Save($perfil);
	
	
//actualiza la tabla "jobs_resume" con los nuevos valores		
    $xoopsDB->query("update ".$xoopsDB->prefix("jobs_resume")." set cid='$cat', name='$name', title='$title', tipoid='$tipoid', numid='$numid', sexo='$sexo', exp='$exp', expire='$expire', private='$private', estadocivil='$estadocivil', fechanac='$fechanac', etnia='$etnia', tel='$tel', tel2='$tel2', celular='$celular', salary='$salary', typeprice='$typeprice', date='$date', email='$email', submitter='$submitter', ciudad='$ciudad', town='$town', barrio='$barrio', perfil='$perfil', trabajo='$trabajo', sector='$sector', empresa='$empresa', telempresa='$telempresa', extempresa='$extempresa', cargo='$cargo', empresanterior='$empresanterior', estudios='$estudios', area='$area', institucion='$institucion', ingles='$ingles', idioma2='$idioma2', intereses='$intereses', areainteres='$areainteres', proyectos='$proyectos', nomproyecto='$nomproyecto', evento='$evento', nomeventos='$nomeventos', cargoeventos='$cargoeventos', cargofunlam='$cargofunlam', distinciones='$distinciones', valid='$valid', resume='$resume_old' where lid=$lid");
	
	include('conexion.php'); // llama el archivo de la conexion
    $conn= conexion();  // crea una variable que almacene la conexion 
	// actualiza la base de datos "egresados" con los nuevos valores
        $datenow = date('Y-m-d');
	$sql= mysql_query("update egresados set NOMBRE='$name', ESTADO_CIVIL='$estadocivil', DIRECCION1='$town', TELEFONO1='$tel', CELULAR='$celular', EMAIL='$email', MUNICIPIO_RESIDENCIA='$ciudad', CUALGRUPO='$etnia', OTROS_ESTUDIOS='$area', NIVEL_INGLES='$ingles', OTRO_IDIOMA='$idioma2', INTERES_FORMACION='$intereses', AREA_INTERES='$areainteres', TIPO_CONTRATO='$trabajo', EMPRESA_LABORA='$empresa', SECTOR='$sector', TELEFONO2='$telempresa', CARGO='$cargo', EMPRESA_ANTERIOR='$empresanterior', PROYECTOFUNLAM='$proyectos', VINCULADOFUNLAM='$cargofunlam', EVENTOS='$evento', CUAL_EVENTO='$nomeventos', CUAL_RECONOCIMIENTO='$distinciones',FECHA_ACTUALIZACION = '$datenow' where CEDULA='$numid'",$conn);
	
    redirect_header("index.php",2,_JOBS_RES_MOD);
	exit();
}

####################################################
foreach ($HTTP_POST_VARS as $k => $v) {
	${$k} = $v;
}

$ok = isset( $_GET['ok'] ) ? $_GET['ok'] : '' ;

if(!isset($_POST['lid']) && isset($_GET['lid']) ) {
	$lid = $_GET['lid'] ;
}
if(!isset($_POST['op']) && isset($_GET['op']) ) {
	$op = $_GET['op'] ;
}

switch ($op) {

    case "ModResume":
	include(XOOPS_ROOT_PATH."/header.php");
    ModResume($lid);
 echo "<br /><br />
<div align=\"center\">" . _INFO_PAG . "</div>
<br /><br />";

	include(XOOPS_ROOT_PATH."/footer.php");
    break;
	
	case "ModResumeS":
	    $cargofunlam = $cargofunlam1 . "," . $cargofunlam2 . "," . $cargofunlam3 . "," . $cargofunlam4;
    ModResumeS($lid, $cid, $name, $title, $tipoid, $numid, $sexo, $exp, $expire, $private, $programa, $programa3, $estadocivil, $fechanac, $etnia, $tel, $tel2, $celular, $salary, $typeprice, $date, $email, $submitter, $ciudad, $town, $barrio, $perfil, $trabajo, $sector, $empresa, $telempresa, $extempresa, $cargo, $empresanterior, $estudios, $area, $institucion, $ingles, $idioma2, $intereses, $areainteres, $proyectos, $nomproyecto, $evento, $nomeventos, $cargoeventos, $cargofunlam, $distinciones, $valid, $resume, $resume_old, $resume_size, $resume_name, $_FILES, $supprim, $mydirname);
    break;

    case "ResumeDel":
	include(XOOPS_ROOT_PATH."/header.php");
    ResumeDel($lid, $ok);
	include(XOOPS_ROOT_PATH."/footer.php");
    break;

    default:
	redirect_header("index.php",1,""._RETURNANN."");
	break;
}
 }else
{
// Usuario que no se ha logueado
echo "No tienes permiso para entrar a esta p�gina...";
exit();
} 
?>
